﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

namespace MyVocationSpace
{
    public partial class CreateMentorsTopic : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BAL.conn.connectionString = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
            if (Session["UserID"] == null)
            {
                Response.Redirect("Home.aspx");
            }
            else
            {
                if (!IsPostBack)
                {
                    int UserId = Convert.ToInt32(Session["UserID"].ToString());
                    BAL.Vocation.PopulateVocation(UserId, ref ddlVocation);
                    BAL.Users.PopulateMyMentor(ref ddlMentor, Convert.ToInt32(Session["UserID"]));
                }
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string name = txtMTName.Text;
            int IDMentor =Convert.ToInt32(ddlMentor.SelectedValue);
            int vocationname = Convert.ToInt32(ddlVocation.SelectedValue);
            string description = txtMTDescription.Text;
            int UserId = Convert.ToInt32(Session["UserID"].ToString());
            int topicId = BAL.Vocation.InsertMentorsBlogTopic(name, vocationname, description, UserId, IDMentor);
            int IsMentor = BAL.Vocation.SelectIsMentor(topicId);
            Span1.Style.Add("Display", "block");
            Span1.InnerHtml = "Record Inserted Successfully";
            // Response.Redirect("~/Blog.aspx?topicId=" + topicId + "&IsMentor=" + IsMentor); // As per Client's Email
            Response.Redirect("MyVocation.aspx");
            clear();
        }
        public void clear()
        {
            txtMTName.Text = "";
            txtMTDescription.Text = "";
            ddlVocation.SelectedValue = "-1";
        }
       
    }
}